<!doctype html>
<html>
 <head>
	<meta charset="UTF-8">
	<meta name="Generator" content="EditPlus®">
	<meta name="Author" content="">
	<meta name="Keywords" content="">
	<meta name="Description" content="">
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<meta name="renderer" content="webkit">
  <link rel="shortcut icon" type="image/x-icon" href="http://oydt3ttm3.bkt.clouddn.com/{{ $sate['icon'] }}">
	<title>{{ $sate['name'] }}</title>
	<link rel="stylesheet" type="text/css" href="{{ asset('css/base.css') }}">
  <link rel="stylesheet" type="text/css" href="{{ asset('css/login.css') }}">
	<link rel="stylesheet" type="text/css" href="{{ asset('btn.css') }}">
 </head>
 <body>

<!--- header begin-->
<header id="pc-header">
    <div class="login-header" style="padding-bottom:0">
        <div><h1><a href="index.html">
    			<a href="{{ route('Home.index') }}"><img src="http://oydt3ttm3.bkt.clouddn.com/{{ $sate['logo'] }}" style="width:190px"></a>
    		</a></h1></div>
    </div>
</header>
<!-- header End -->

<section id="login-content">
    <div class="login-centre">
        <div class="login-back">
            <div class="H-over">
                <form method="post" action="{{ route('home.dochangepass') }}" class="form form-horizontal" id="form-addUser">
                  {{ csrf_field() }}

                    <center>
                        @if (session('message'))
                    		<div class="Huialert Huialert-error">
                    			<h3 style="color:red;margin-top:10px;">{{ session('message') }}</h3>
                    		</div>
                    		@endif
                        @if (count($errors) > 0)
                        <div class="Huialert Huialert-danger">
                          <ul>
                            @foreach ($errors->all() as $error)
                            <li><h3 style="color:red;margin-top:10px;">{{ $error }}</h3></li>
                            @endforeach
                          </ul>
                        </div>
                        @endif
                    </center>

                    <div class="login-input">
                      <label><i class="heart">*</i>手机号：</label>
                      <input type="text" id="phone" readonly unselectable="on" style="background:#ccc;" value="{{ $user->phone }}" class="list-input" name="phone" placeholder="">
                    </div>

                    <div class="login-input">
                        <label><i class="heart">*</i>请设置密码：</label>
                            <input type="password" class="list-input" id="password" name="password" placeholder="你要修改的密码">
                    </div>

                    <div class="login-input">
                        <label><i class="heart">*</i>请确认密码：</label>
                        <input type="password" class="list-input" id="password_confirmation" name="password_confirmation" placeholder="再次确认要修改的密码">
                    </div>


                    <div class="login-input">
                        <label><i class="heart">*</i>短信验证码：</label>
                        <input type="text" class="list-iphone" id="code" name="code" placeholder="接收到的短信验证码">
                        <i id="phonecode" style="margin-left:5px;background:#ccc;width:118px;margin-right:10px;" class="button button-action button-rounded">获取</i>
                        <h3 id="phonecode-error" style="color:red;margin-top:10px;"></h3>
                        @if (session('sendphone'))
        									  <h3 id="sendphone-error" style="color:red;margin-top:10px;">{{ session('sendphone') }}</h3>
        								@endif
                    </div>

                    <div style="margin-left:100px;">
                        <div class="login-button">
                            <input type="submit" id="submit"  style="width:280px;background:red;" value="立即修改" class="button button-highlight button-rounded button-large">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>

<!--- footer begin-->
<footer id="footer">
  <div class="w">
  	<div id="footer-2013">
  		<div class="aui-footer-bot">
  			<center>
  		    <ul class="time-lists aui-footer-pd clearfix" style="padding:50px;">
  		        <li class="aui-footer-list clearfix" style="padding-left:90px;width:120px;display:inline-block;">
  		            <h4>
  		                <span><img src="{{ asset('icon/icon-d1.png') }}"></span>
  		                <em>消费者权益</em>
  		            </h4>
  		        </li>
  		        <li class="aui-footer-list clearfix" style="padding-left:10px;width:120px;display:inline-block;">
  		            <h4>
  		                <span><img src="{{ asset('icon/icon-d2.png') }}"></span>
  		                <em>新手上路</em>
  		            </h4>
  		        </li>
  		        <li class="aui-footer-list clearfix" style="padding-left:10px;width:120px;display:inline-block;">
  		            <h4>
  		                <span><img src="{{ asset('icon/icon-d3.png') }}"></span>
  		                <em>保障正品</em>
  		            </h4>
  		        </li>
  		    </ul>
  			</center>
  		    <div style="border-bottom:1px solid #dedede"></div>
  		    <div class="time-lists aui-footer-pd time-lists-ls clearfix">

  		        <div class="aui-footer-list clearfix">
  		            <h4>友情链接</h4>
  		            <ul>
  		                @foreach ($linksArray as $linkArray)
  		                <li><a href="{{ $linkArray['url'] }}"> {{ $linkArray['name'] }} </a> </li>
  		                @endforeach
  		            </ul>
  		        </div>
  		    </div>
  		    <div class="time-lists aui-footer-pd time-lists-ls clearfix">
            <p><h3 style="width:1200px;text-align: center">{{ $sate['desc'] }}</h3></p>
            <p><h3 style="width:1200px;text-align: center">{{ $sate['message'] }}</h3></p>
            <p><h3 style="width:1200px;text-align: center">{{ $sate['record'] }}</h3></p>
  		    </div>
  		</div>
  	</div>
  </div>
</footer>
<!-- footer End -->
</body>
<script type="text/javascript" src="{{asset('AdminPublic/lib/jquery/1.9.1/jquery.min.js')}}"></script>
<script type="text/javascript">
var sendstatus = '0';
var captchacode = '1';
var number = 1;

// 判断密码
$('#phonecode').off('click');
$('#password').blur(function() {
    var password = $('#password').val();

    $('#password').next().remove();

    if (password == '') {
        $('#password').after('<h3 id="password-error" style="color:red;margin-top:10px;">　密码不能为空</h3>');
        return false;
    }

    if (password.length < 6) {
        $('#password').after('<h3 id="password-error" style="color:red;margin-top:10px;">　密码不能少于6个字符</h3>');
        return false;
    }

    if (password.length > 100) {
        $('#password').after('<h3 id="password-error" style="color:red;margin-top:10px;">　密码不能多于100个字符</h3>');
        return false;
    }
});

// 判断确认密码
$('#password_confirmation').blur(function() {

    $('#password_confirmation').next().remove();

    var password_confirmation = $('#password_confirmation').val();
    var password = $('#password').val();

    if (password_confirmation !== password) {
        $('#password_confirmation').after('<h3 id="password_confirmation-error" style="color:red;margin-top:10px;">　两次密码不相同</h3>');
        return false;
    }

    if (password_confirmation == '') {
        $('#password_confirmation').after('<h3 id="password_confirmation-error" style="color:red;margin-top:10px;">　确认密码不能为空</h3>');
        return false;
    }

});

// 判断手机号码
$('#phone').blur(function() {

    $('#phone').next().remove();

    var phone = $('#phone').val();
    var password = $('#password').val();

    if (phone == '') {
      $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号码不能为空</h3>');
      $('#phonecode').click(function() {
          $('#phone').next().remove();
          $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　请先填写手机号</h3>')
      });
      return false;
    }

    if (phone.length < 11) {
        $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号码不能少于11位</h3>');
        $('#phonecode').click(function() {
            $('#phone').next().remove();
            $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　请先重新填写手机号</h3>')
        });
        return false;
    }

    if (phone.length > 11) {
        $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号码不能大于11位</h3>');
        $('#phonecode').click(function() {
            $('#phone').next().remove();
            $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　请先重新填写手机号</h3>')
        });
        return false;
    }

    if (phone.length === 11) {
          var result = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u;
          if (!result.test(phone)) {
          $('#phone').next().remove();
          $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号不正确，请重新输入</h3>');
          return false;
        }
    }

    $.ajax({
      type: 'post',
      url: "{{ route('home.showphone') }}",
      data: "phone="+ phone +"&_token={{ csrf_token() }}",
      dataType: 'JSON',
      success:function(data)
      {
            $('#phonecode-error').html('');
            if (data == 2) {
                $('#phone').next().remove();
                $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　该手机号未注册</h3>');
                $('#phonecode').click(function() {
                    $('#phonecode-error').html('');
                    $('#phonecode-error').html('请先重新填写手机号');
                });
                return false;
            }
        }
    });
});

$('#code').blur(function() {

    var emailcode = $('#emailcode').val();
    var bindemail = $('#bindemail').val();

    $.ajax({
        type: 'post',
        url: "{{ route('home.validatachangepass') }}",
        data: "bindemail=" + bindemail + "&code=" + emailcode + "&_token={{ csrf_token() }}",
        dataType: 'JSON',
        success:function(data)
        {
            captchacode = data;
        }
    });
});


$('#phonecode').click(function() {

    var phone = $('#phone').val();
    if (number > 1) {
        return false;
    }

    $.post("{{ route('home.changepass') }}", { "phone": phone, "_token": "{{ csrf_token() }}" },function(data) {
        sendstatus = data;
        if (sendstatus == 403) {
          $('#phonecode-error').html('');
          $("#phonecode-error").html('90秒内只能获取一次！');
          return false;
        }
        if (sendstatus !== 200) {
          $('#phonecode-error').html('');
          $("#phonecode-error").html('短信发送失败，请重新获取!');
          return false;
        }
        $('#phonecode-error').html('');

        var time = 90;

        number++;

        var marke = setInterval(function() {

            time--;
            $('#phonecode-error').html("(" + time + ")后重新获取");
            $("#phonecode").html("(" + time + ")");

            if (time < 1) {
                clearInterval(marke);
                number = 1;
                $("#phonecode").html('获取');
            }

        }, 1000);

    },'json');
});


$("#submit").click(function(evn) {

    evn = evn || window.event;

    var code = $('#code').val();
    var phone = $('#phone').val();
    var password = $('#password').val();
    var password_confirmation = $('#password_confirmation').val();

    $('#password').next().remove();
    $('#password_confirmation').next().remove();
    $("#phone").next().remove();
    $('#phonecode-error').html('');
    $('#readme-error').html('');

    // 判断密码
    if (password == '') {
        $('#password').next().remove();
        $('#password').after('<h3 id="password-error" style="color:red;margin-top:10px;">　密码不能为空</h3>');
        evn.preventDefault();
        return false;
    }

    if (password.length < 6) {
        $('#password').next().remove();
        $('#password').after('<h3 id="password-error" style="color:red;margin-top:10px;">　密码不能少于6个字符</h3>');
        evn.preventDefault();
        return false;
    }

    if (password.length > 100) {
        $('#password').next().remove();
        $('#password').after('<h3 id="password-error" style="color:red;margin-top:10px;">　密码不能多于100个字符</h3>');
        evn.preventDefault();
        return false;
    }


    // 判断确认密码
    if (password_confirmation !== password) {
        $('#password_confirmation').next().remove();
        $('#password_confirmation').after('<h3 id="password_confirmation-error" style="color:red;margin-top:10px;">　两次密码不相同</h3>');
        evn.preventDefault();
        return false;
    }

    // 判断手机号码
    if (phone == '') {
      $("#phone").next().remove();
      $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号码不能为空</h3>');
      evn.preventDefault();
      evn.preventDefault();
      return false;
    }

    if (phone.length < 11) {
        $("#phone").next().remove();
        $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号码不能少于11位</h3>');
        evn.preventDefault();
        return false;
    }

    if (phone.length > 11) {
      $("#phonev").next().remove();
      $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号码不能大于11位</h3>');
      evn.preventDefault();
      return false;
    }

    var result = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/u;
    if (!result.test(phone)) {
      $("#phone").next().remove();
      $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　手机号不正确，请重新输入</h3>');
      evn.preventDefault();
      return false;
    }

    $.ajax({
      type: 'post',
      url: "{{ route('home.showphone') }}",
      data: "phone="+ phone +"&_token={{ csrf_token() }}",
      dataType: 'JSON',
      success:function(data)
      {
          confirm = data;
          evn.preventDefault();
          return false;
      }
    });

    if (confirm == 2) {
      $("#phone").next().remove();
      $('#phone').after('<h3 id="phone-error" style="color:red;margin-top:10px;">　该手机号并未注册</h3>');
      evn.preventDefault();
      return false;
    }

    if (code == '') {
      console.log(code);
      $('#phonecode-error').html('');
      $('#phonecode-error').html('验证码不能为空');
      evn.preventDefault();
      return false;
    }

    if (code.length < 6) {
      $('#phonecode-error').html('');
      $('#phonecode-error').html('验证码不能少于六位');
      evn.preventDefault();
      return false;
    }

    if (code.length > 6) {
      $('#phonecode-error').html('');
      $('#phonecode-error').html('验证码不能多于六位');
      evn.preventDefault();
      return false;
    }

    $.ajax({
        type: 'post',
        url: "{{ route('home.validatachangepass') }}",
        data: "phone="+ phone +"&code="+ code +"&_token={{ csrf_token() }}",
        dataType: 'JSON',
        success:function(data)
        {
            captchacode = data;
        }
    });

    if (captchacode == "403") {
      $('#phonecode-error').html('');
      $('#phonecode-error').html('验证码已过期');
      evn.preventDefault();
      return false;
    }

    if (captchacode == "500") {
      $('#phonecode-error').html('');
      $('#phonecode-error').html('验证码不正确');
      evn.preventDefault();
      return false;
    }

    if (captchacode == "1") {
      $('#phonecode-error').html('');
      $('#phonecode-error').html('验证码不正确');
      evn.preventDefault();
      return false;
    }

});




</script>
</html>
